<!-- head -->
{include file='public/head' /}
<!-- head -->

<!-- left -->
{include file='public/left' /}
<!-- left -->

<div class="content-wrapper">
    <section class="content-header">
        <h1>
            分配店铺
            <small>审核通过</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 店铺管理</a></li>
            <li class="active">分配店铺</li>
        </ol>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-sm-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">共计{$storeList->total()}条记录</h3>
                        <div class="box-tools pull-right">
                            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                            </button>
                            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                        </div>
                    </div>
                    <div class="box-body">
                        <div class="table-responsive">
                            <table class="table table-bordered table-striped">
                                <form id='iform' action="{:url('Store/AssignStore')}" method="get">
                                    <div class="input-group">
                                        <input type="text" name="store_name" value="{$store_name}" class="form-control" style="width: 30%;" placeholder="请输入店铺名...">
                                        <input type="text" name="phone" value="{$phone}" class="form-control" style="width: 30%;" placeholder="请输入负责人手机号...">

                                        <select class="form-control select2" name="provdata" id='provdata' style="width: 20%;">
                                            <option value="0">请选择省份</option>
                                            {volist name='prov' id='prov'}
                                            {if condition="$prov['id'] eq $provdata"} 
                                            <option selected="selected" value="{$prov.id}">{$prov.name}</option>
                                            {else/}
                                            <option value="{$prov.id}">{$prov.name}</option>
                                            {/if}
                                            {/volist}
                                        </select>
                                        <div class="input-group date">
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>
                                            <input type="text" class="form-control pull-right" name="starttime" value="{$starttime}" id="datepicker" placeholder="选择开始时间..." autocomplete="off">
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>
                                            <input type="text" class="form-control pull-right" name="endtime" value="{$endtime}" id="datepicker1" placeholder="选择结束时间..." autocomplete="off">
                                        </div>
                                        <span class="input-group-btn">
                                            <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i></button>
                                            <!--<button type="button" class="btn btn-flat bg-olive" data-url="{:url('Store/storeExcel','','')}" onclick="storeExcel(this)"><i class="fa fa-download"></i></button>-->
                                        </span>
                                    </div>
                                </form>
                                <thead>
                                    <tr>
                                        <th>选择</th>
                                        <th>编号</th>
                                        <th>店名</th>
                                        <th>法人</th>
                                        <th>级别</th>
                                        <th>到期时间</th>
                                        <th>地区</th>
                                        <th>手机</th>
                                        <th>注册时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="list">
                                    {volist name='storeList' id='admin'}
                                    <tr>
                                        <td><input type="checkbox" value="{$admin.id}"></td>
                                        <td>{$admin.id}</td>
                                        <td>{$admin.store_name}</td>
                                        <td>{$admin.store_keeper}</td>
                                        <td>
                                            {if condition="$admin.level eq 1"}体验版
                                            {elseif condition="$admin.level eq 2"}标准版
                                            {elseif condition="$admin.level eq 3"}专业版
                                            {/if}
                                        </td>
                                        <td>
                                            {if condition="$admin.expire_time eq ''"}
                                            ∞
                                            {else/}
                                            {$admin.expire_time|date="Y-m-d H:i:s",###}
                                            {/if}
                                        </td>
                                        <td>{$admin.prov_city_area.name}</td>
                                        <!--<td class="ord_phone">{$admin.keeper_phone}</td>-->
                                        <td><a href ="javascript:volid(0);" style="text-decoration: none;color: #000000;" title="{$admin.keeper_phone}" target='_blank' class="ord_phone">{$admin.keeper_phone}</a></td>
                                        <td>{$admin.add_time|date='Y-m-d H:i',###}</td>
                                        <td style="width: 100px; text-align:right;">
                                            <button type="button" class="btn btn-sm bg-olive" data-url="{:url('selladmin/Store/ShowImgMessage',['id'=>$admin.id],'')}" onclick="ShowMessage(this)">查看信息 </button>&nbsp;
                                            <!--                                            <button type="button" class="btn btn-sm btn-info" data-url="{:url('admin/Store/editStore',['id'=>$admin.id],'')}" onclick="edit(this)">修改</button>&nbsp;
                                                                                        <button type="button" class="btn btn-sm btn-danger" onclick="del({$admin.id})">删除</button>
                                                                                        <button type="button" class="btn btn-sm bg-orange" onclick="end({$admin.id})">下架体验卡</button>-->
                                        </td>
                                    </tr>
                                    {/volist}
                                    <tr>
                                        <td colspan="2">
                                            <input type="button" value="全选" class="btn" id="selectAll">   
                                            <input type="button" value="全不选" class="btn" id="unSelect">   
                                            <!--<input type="button" value="获得选中的所有值" class="btn" id="getValue">--> 
                                        </td>
                                        <td><b>分配给</b></td>
                                        <td colspan="2">
                                            <select class="form-control select2" style="" name="adminid" id="testSelect">
                                                {volist name='selladmin' id='selladmin'}
                                                {if condition="$selladmin['id'] eq $adminid"}
                                                <option value="{$selladmin.id}" selected>{$selladmin.admin_note}</option>
                                                {else/}
                                                <option value="{$selladmin.id}">{$selladmin.admin_note}</option>
                                                {/if}
                                                {/volist}
                                            </select>
                                        </td>
                                        <td ><input type="button" value="确认分配" class="btn btn-sm bg-orange" id="getValue"></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="box-footer clearfix" style="text-align: center">
                        {$storeList->render()}
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<script src="__STATIC__/AdminLTE/plugins/select2/select2.full.min.js"></script>
<script type="text/javascript">
    function ShowMessage(obj) {
    var url = $(obj).data('url');
    window.location.href = url;
    }
    $(function () {
        var ord_phone = $(".ord_phone");
        for (var i = 0; i < ord_phone.length; i++) {
            var cnd = $(".ord_phone").eq(i).text();
            var mpcnd = cnd.substr(0, 3) + '****' + cnd.substr(7);
            $(".ord_phone").eq(i).text(mpcnd);
        }

    });
    $("#selectAll").click(function () {
        $("#list input[type='checkbox']").prop("checked", "checked");
    });
    $("#unSelect").click(function () {   
        $("#list input[type='checkbox']").prop("checked", "");   
     });  
    $("#getValue").click(function(){ 
        var sell_id = $('#testSelect option:selected') .val();
        var valArr = new Array; 
        $("#list input[type='checkbox']:checked").each(function(i){ 
            valArr[i] = $(this).val(); 
        }); 
        var vals = valArr.join(',');//转换为逗号隔开的字符串 
        
        $.ajax({
            url: "{:url('Store/AssignStore2','','')}",
            type: 'POST',
            data: {
                'store_ids': vals,
                'sell_id': sell_id,
            },
            dataType: 'JSON',
            success: function (data) {
                showAlert('提示', data.msg, null);
                if (data.code == 0) {
                   showAlert('提示', data.msg, null);
                   //window.location.href="{:url('Store/AssignStore')}";  
                }
            }
        });
    }); 
</script>

<!-- foot -->
{include file='public/foot' /}
<!-- foot -->